extends Control

#---------------------变量声明-----------------------#
@onready var bag:Bag=get_parent().bag
@onready var cells:Array=$NinePatchRect/GridContainer.get_children()

#---------------------生命周期-----------------------#
func _ready() -> void:
    bag.updateCell.connect(updateCell)
    visible=false
    updateCell()

func _physics_process(_delta: float) -> void:
    if Input.is_action_just_pressed('背包'):visible=!visible

#---------------------响应函数-----------------------#
func updateCell():
    for i in range(min(bag.cells.size(),cells.size())):cells[i].update(bag.cells[i])

